home *** CD-ROM | disk | FTP | other *** search
-
- ;write current and neighbour boxes with options to screen
-
- write_chart:
- call get_current_routes ;copy current route data to route store
- mov w stem_start,1 ;write 3 top vertical double bars
- mov b cursor_pos,39 ;store cursor coords for stem
- mov cx,2 ;load arrow key jump address count
- mov di,o akey_jump ;load pointer to cursor key table
- mov es,ax,cs
- xor ax,ax ;clear register
- rep
- stosw ;clear jump addresses
-
- ;clear screen
-
- mov w cursor_pos+1,ax
- mov b command_line,al ;clear command row string
- mov b descripter_string,al ;clear box descripter string buffer
- call cls ;clear the screen
- mov es,ax,cs ;copy code segment
-
- ;write options to screen
-
- mov cx,option_count ;load loop count
- xor bx,bx ;load offset to options available
- mov di,o command_line ;load offset to command line
- a1:
- push cx ;save loop count
- cmp b[bx+option_array+2],1 ;is option available?
- jne >a2 ;check if it is existing route if not
-
- ;check if C option is 'create' or 'cancel'
-
- xor dx,dx ;assume 'create' option
- cmp bx,2 ;is option create/cancel?
- jne >a3 ;check for 'A' option if not
- cmp w box_save,0 ;is it 'create' option?
- je >a3 ;calculate offset to string if it is
- mov dx,option_count*2-2 ;load offset to cancel string
-
- ;create option string and add it to command line
-
- a3:
- mov si,bx ;load offset to options array
- add si,dx ;add cancel offset
- mov si,w[si+options_table] ;load offset to option
-
- ;get length of option string
-
- push si ;save offset to start of string
- a3:
- lodsb ;load character from string
- or al,al ;is it last character
- jne a3 ;get next character if not
- mov cx,si ;load offset to end of string
- dec cx ;move it over zero byte
- pull si ;restore offset to start of string
- sub cx,si ;calculate length of string
-
- ;check if option string can be added to command line
-
- mov ax,di ;load offset to end of command line
- sub ax,o command_line ;calculate length of string
- add ax,cx ;add it to option string length
- add ax,2 ;add 2 for full stop and space
- cmp ax,78 ;can option string be added?
-
- ;write command line to screen
-
- if a call write_command_line ;write remainder of options
- rep
- movsb ;copy option string
- mov ax,0202eh ;load option terminator string
- stosw ;write it to end of option
-
- ;move to next option
-
- a2:
- pull cx ;restore loop count
- add bx,2 ;move to next option
- loop a1 ;decrement loop count
- call write_command_line ;write remainder of options
-
- ;write neighbour and current boxes to screen
-
- mov b err,5 ;set stem flags
- mov cx,4 ;assume there is a neighbour box
- cmp w routes,0 ;is there?
- jne >a1 ;load stem character for lead to
- ;neighbour box if there is
- mov cx,6 ;load stem count
- mov b err,0 ;indicate no leading box
-
- ;load stem character for lead to neighbour box
-
- a1:
- cmp cx,4 ;is there a leading box?
- jne >a1 ;move cursor row coordinate if not
- mov ax,w routes ;load neighbour box
- xor bx,bx ;load element
- call get_box_par ;get neighbour of neighbour box
- or ax,ax ;is there one?
- if e and b err,4 ;indicate no leading stem to leading box
-
- ;calculate length of leading stem
-
- a1:
- test b err,1 ;is there a leading stem to leading box?
- if e inc cx ;increment size of stem if not
- sub cx,w cursor_pos+1 ;calculate length of leading stem
- mov dx,b cursor_pos ;load starting row
- add w cursor_pos+1,cx ;add length of stem to row marker
- test b err,1 ;is there a leading stem to leading box?
- je >a1 ;check if there is a leading stem to
- ;centre box if not
-
- ;write leading stem to leading box to screen
-
- call write_stem ;write stem to screen
- inc b cursor_pos+1 ;increment cursor row
- call cursor ;position cursor
- mov al,208 ;load bottom stem character
- call write_chr ;write it to bottom of leading stem
-
- ;write leading box to screen
-
- a1:
- test b err,4 ;is there a leading stem to centre box?
- je >b1 ;
- mov ax,w routes ;load neighour box of current box
- mov bx,ax
- mov cx,4 ;indicate box is leading box
- mov w main_route,0 ;clear route
- call write_box ;write box to screen
-
- ;write route and subchart indicators to stem
-
- test b err,4 ;is there a leading stem to current box?
- if ne call write_indicator ;write stem chr and indicator string
-
- ;write remainder of leading stem to screen
-
- b1:
- mov cx,4 ;calcuate length of leading stem
- sub cx,w stem_start
- mov dx,w cursor_pos ;load cursor coords for rest of stem
- add w cursor_pos+1,cx ;add it to row coordinate
- inc w cursor_pos+1 ;increment row coordinate
- test b err,4 ;is there a leading stem?
- je >b1 ;increment row coordinate if not
-
- ;write leading stem to current box to screen
-
- call write_stem ;write stem to screen
- call cursor ;position cursor
- mov al,208 ;load bottom stem character
- call write_chr ;write it to bottom of stem
-
- ;store centre box
-
- b1:
- mov w centre_box,bp ;store it as current box
- mov ax,w insert_mode ;is box being inserted?
- mul w box_save
- or ax,dx
- je >a1 ;clear descripter string buffer if not
- cmp w key_option,0 ;is there a key option?
- jne >a1 ;clear descripter string buffer if not
- mov ax,w box_save ;copy main box as centre box
- mov w centre_box,ax
-
- ;clear descripter string buffer
-
- a1:
- mov dx,w link_box ;load link box
- mov di,o descripter_string ;load offset to buffer
- cmp w key_option,0 ;is there a key option?
- jne >a1 ;copy route string if there is
- cmp b link_string,0 ;is there a link string?
- jne >b1 ;copy box decripter string if there is
- mov ax,w box_save ;load main box
- or ax,ax ;is flowchart dormant?
- je >a1 ;copy route string if it is
- cmp ax,bp ;is current box main box?
- jne >b1 ;copy box descripter string if not
-
- ;copy route string to descripter string buffer
-
- a1:
- mov si,o route_string ;load offset to string
- lodsw ;copy characters from it
- or al,al ;is string empty?
- je >a1 ;load centre box if it is
- stosw
- lodsb
- stosb ;write character to descripter buffer
- a1:
- mov dx,w centre_box ;load centre box
-
- ;store box descripter in buffer
-
- b1:
- mov w view_box,dx ;store it
- mov ax,' :' ;load separator character
- stosw ;store it in descripter string
- mov ax,w centre_box ;load centre box
- call get_box_descripter ;copy box descripter string
- rep
- movsb ;copy box descripter string
- mov ds,ax,cs ;restore data segment register
-
- ;calculate size of descripter string
-
- sub di,o descripter_string ;calculate length of string
- mov w descripter_count,di ;save it
- mov dx,bp ;load current box
- mov di,2 ;load loop flag
- mov b err,0 ;clear box flags
- mov w main_route,0 ;clear forced routes
- mov w follow_route,0
-
- ;check if flowchart is dormant
-
- mov ax,w insert_mode ;load flowchart dormant flag
- or ax,ax ;is it?
- je >c1 ;calculate routes for boxes if not
- cmp ax,1 ;is user choosing route for inserted box
- je >a1 ;copy main box if yes
- mov ax,w route ;load current route
- mov w follow_route,ax ;store it as forced route
- mov w main_route,ax
- jmp >c1 ;write remaining boxes to screen
- a1:
- mov dx,w box_save ;load main box
-
- ;calculate following routes for remaining boxes
-
- c1:
- mov ax,dx ;load box being written to screen
- call get_routes ;copy its routes
- mov si,no ;load route element
- cmp w follow_route,0 ;has a route been found?
- jne >b1 ;save it if it has
-
- ;find a next route
-
- a1:
- mov bx,w[si+routes] ;load route of box
- mov ax,dx ;load box
- call get_route ;got box of route
- or ax,ax ;is there a route?
- if ne mov w follow_route,si ;save route element if it is
- dec si,2 ;move back a route
- jne a1 ;decrement loop count
-
- ;check if there is a route
-
- b1:
- cmp w follow_route,0 ;is there a route?
- je >b3 ;copy descripter for centre box if not
- b2:
- cmp di,1 ;is it second loop?
- je >b1 ;indicate trailing stem if it is
-
- ;indicate two more boxes to write
-
- or b err,1 ;indicate there is a following stem from
- mov bx,w follow_route ;load route
- mov ax,dx ;load centre box
- call get_box_par ;get route of following stem
- mov bx,ax ;load centre box
- mov ax,dx ;load box
- call get_route ;get its route
-
- ;decrement loop count
-
- mov w box_of_route,dx ;store box of main route
- dec di ;decrement loop count
- cmp ax,dx ;is route from copied subchart?
- if e mov ax,w subchart_link ;load following box from subchart if yes
- or ax,ax ;is there a route from copied subchart?
- if e mov ax,dx ;restore route if not
- mov w trailing_box,ax ;save following box
- mov dx,ax ;copy following box
- mov w follow_route,0 ;clear its following route
- jmp c1 ;goto start of loop
-
- ;indicate following stem from following box
-
- b1:
- or b err,2 ;indicate stem for following box
- b3:
- mov ax,w centre_box ;calculate centre box number
- sub ax,first_box-1
- call store_number ;store it at start of buffer
- mov si,o link_string ;load offset to start of link string
- a1:
- lodsb ;read character from link string
- or al,al ;last character?
- je >b1 ;write centre box if it is
- stosb ;write character to end of buffer
- jmp a1 ;read next character
-
- ;write centre box to screen
-
- b1:
- mov w box,dx ;save centre box
- mov ax,dx
- mov bx,w centre_box ;load centre box
- mov cx,1 ;indicate box is centre box
- call write_box ;write centre box to screen
-
- ;write trailing stem from centre box
-
- call write_indicator ;write indicator string below box
- test b err,1 ;is there a following box?
- je >b1 ;write message to bottom line if not
- inc w stem_start ;move down a row
- call connect ;write trailing stem to following box
- mov ax,w box ;load following box
- mov bx,w trailing_box ;load its route from centre box
- mov cx,2 ;indicate box is trailing box
- mov w main_route,0 ;clear route
- call write_box ;write box to screen
-
- ;check if there is a trailing stem from trailing box
-
- call write_indicator ;write indicator string below box
- test b err,2 ;is there?
- je >b1 ;write message if not
- inc w stem_start ;increment stem count
- call connect ;write trailing stem from trailing box
-
- ;write message to bottom of screen
-
- b1:
- cmp b message,0 ;is there a bottom line message
- je ret ;exit if not
- mov dx,24*256+79 ;load cursor row and screen width-1
- mov cx,w message_length ;load size of message
- sub dl,cl ;calculate cursor column
- shr dl,1
- call cursor ;position cursor
- mov si,o message ;load offset to message store
- a1:
- lodsb ;load character from message string
- call write_chr ;write it to screen
- loop a1 ;decrement loop count
- ret ;exit
-
- ;fetch keypress and execute option
-
- do_option:
- call key ;get keypress
- jc >b1 ;exit if middle 5 down
- jne >a1 ;make keypress upper case if not escape
- cmp w box_save,0 ;is flowchart dormant?
- jne do_option ;fetch another keypress if not
- b1:
- mov b chart_flag,3 ;indicate flowchart initialised
- mov w current_box,bp ;save current box
- ret ;exit to main loop
-
- ;check if middle 5 has been pressed for the second time
-
- a1:
- cmp al,02dh ;is keypress '-'?
- if e not b direct_video ;toggle screen output flag
-
- ;check for HOME key
-
- cmp ax,04700h ;is keypress home key?
- jne >a1 ;check for letter if not
- push bp ;save current box
- call move_to_first_box ;move to first box in chart
- pull bp ;restore current box
- stc ;goto start of chart loop
- ret ;exit
-
- ;check if keypress is ALT-n
-
- a1:
- xor bx,bx ;clear base register
- mov bl,ah ;load keypress
- sub bl,03bh ;is it below ALT-1?
- jc >a1 ;check if character is a digit if it is
- cmp bx,9 ;is it above ALT-9?
- ja >a1 ;check if character is a digit if it is
- shl bx,1 ;calculate offset to bookmark
- mov w[bx+bookmarks],bp ;set bookmark
- jmp do_option ;get next keypress
-
- ;check if keypress is a digit key (goto bookmark)
-
- a1:
- mov bl,al ;load keypress
- sub bx,'0' ;calculate offset to bookmarks
- jc >a1 ;check for other options if not digit
- sub bx,1 ;is it '0'?
- if c mov bx,9 ;load 10 as bookmark
- cmp bx,9 ;is character a digit?
- ja >a1 ;check other options if not
- shl bx,1 ;calculate offset to table
- mov ax,w[bx+bookmarks] ;load bookmark
- or ax,ax ;is it set to a box
- je do_option ;get another keypress if not
-
- ;check if box is still active
-
- push ax ;save box id
- xor bx,bx ;load offset to neighbour route
- call get_box_par ;get its leading neighbour box
- cmp ax,-1 ;is there one?
- pull ax ;restore box of bookmark
- je do_option ;get another keypress if not
- cmp b option_array+34,0 ;is goto box option available?
- je do_option ;get another keypress if not
- mov bp,ax ;load box of bookmark
- jmp goto_box ;goto box
-
- ;check if keypress is route arrow key
-
- a1:
- and al,05fh ;make it upper case
- mov es,bx,cs ;copy code segment
- mov di,o akeys ;load offset to key values
- mov cx,3 ;load route key count
- repne
- scasw ;is keypress a arrow key?
- jne >a1 ;check if it is alpha if not
-
- ;check if ok for cursor keys
-
- cmp w key_option,0 ;is user choosing a route?
- je >a3 ;check if route for key is available
- e1:
- jmp do_option ;get another keypress if yes
- a3:
- xor bx,bx ;clear entry register
- jcxz >a2 ;check if previous option is available
- ;if key is up key
-
- ;check if arrow key route options are available
-
- cmp w[di+akey_jump_offset],bx ;is arrow route available?
- je e1 ;get another keypress if not
- jmp w[di+akey_jump_offset] ;move to arrow box route
-
- ;check if previous route option is available
-
- a2:
- cmp w option_array+18,bx ;is previous option available?
- je e1 ;get another keypress if not
- jmp move_to_route ;move to leading neighbour box
-
- ;check if keypress is alpha
-
- a1:
- cmp al,'A' ;is keypress upper alpha
- jb e1 ;fetch another keypress if not
- cmp al,'Z' ;is keypress upper alpha?
- ja e1 ;exit if not
-
- ;check if keypress is a option
-
- mov cx,option_count+1 ;load all options count
- mov di,o keys ;load offset to key data
- repne
- scasb ;is keypress a option?
- jne e1 ;fetch another keypress if not
- sub di,o keys ;calculate offset to option data
- shl di,1
- lea di,[di+option_array] ;calculate offset to options
- cmp b[di],0 ;is option available?
- je e1 ;fetch another keypress if not
-
- ;calculate selected option indicator
-
- cmp b[di],1 ;is selected option existing route?
- jbe >b1 ;do option if not
- cmp w insert_mode,0 ;is flowchart dormant?
- if e add di,(option_count-5)*2 ;load select route option if it is
-
- ;jump to option routine address
-
- b1:
- xor bx,bx ;load parameter for route options
- jmp w[di+option_jump_offset] ;jmp to address
-
- ;end